<?php

class ControllerAdmin_Robots_txt extends ControllerAdmin_Base
{
	public function __construct($section) {		
		$this->section      = $section;
		$this->common_vars  = Registry::get("common_vars");
	}	
	public function init() {}
    public function out()
	{		
		$file_path = "../robots.txt";			
		if(file_exists($file_path) && is_file($file_path))
		{			
			if(!empty($_POST["type"])) {	
				$w = fopen($file_path, "w");			
				@fwrite($w, $_POST["text"]);
				fclose($w);
				header("Location: /admin/?m=configuration&id=".$_GET["id"]."&parent=".$_GET["parent"]."");
			}
						
			$w = fopen($file_path, "r");
			$Field["text"] = @fread($w, filesize($file_path));			
			fclose($w);
		}
		else {
			fopen($file_path, "w");
		}		
		Registry::get("smarty")->assign(array(
			'SECTION'   => $this->section,				
			'Field'     => $Field
		));
		return Registry::get("smarty")->fetch(
			TEMPLATE_ADMIN.$this->common_vars["controller_template"], 
			Registry::get("cache_id")
		);
    }
}

$controller = new ControllerAdmin_Robots_txt($section);
$ob_admin_out = $controller->out();

?>